package com.yswy.backstage.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yswy.backstage.dto.req.PackageManageAddUpdateVo;
import com.yswy.backstage.dto.req.PackageManageListVo;
import com.yswy.backstage.service.PackageManageService;
import com.yswy.domain.entity.PackageManage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

import static com.yswy.backstage.utils.GldTokenUtils.getUser;

@RestController
@RequestMapping("/pack")
@ApiModel("渠道包")
public class PackageManageController {

    @Autowired
    private PackageManageService packageManageService;

    @PostMapping("/listPackageManage")
    @ApiOperation(value = "包列表")
    public Page<PackageManage> listPackageManage(@RequestBody @Validated PackageManageListVo filter, HttpServletRequest request) {
        return packageManageService.listPackageManage(filter);
    }

    @PostMapping("/addOrUpdate")
    @ApiOperation(value = "添加或修改包")
    public void addOrUpdate(@ModelAttribute @Validated PackageManageAddUpdateVo filter, HttpServletRequest request) {
        packageManageService.addOrUpdate(filter ,getUser(request));
    }

    @GetMapping("/delPackageManage")
    @ApiOperation(value = "删除包")
    public void delPackageManage(@RequestParam(value = "id") Long id, HttpServletRequest request) {
        packageManageService.delPackageManage(id ,getUser(request));
    }
}



